package com.jy.wms.controller;


import com.alibaba.fastjson.JSON;
import com.joyi.gate.comm.SessionInfo;
import com.joyi.gate.safety.vo.UserInfo;
import com.jy.wms.common.PropertyUtil;
import com.jy.wms.common.SetStatus;
import com.jy.wms.common.base.*;
import com.jy.wms.pojo.*;
import com.jy.wms.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.sf.json.JSONObject;
import org.omg.PortableInterceptor.USER_EXCEPTION;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @ClassName: SysUserController
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @Author zzp
 * @Date Tue Aug 29 14:54:16 CST 2017
 */
@Controller
@RequestMapping("/sysuser1")
@Api(value = "/sysuser", description = "关于用户管理操作")
public class SysUserController1 extends BaseController<SysUserService, SysUser> {
    private static Logger log = LoggerFactory.getLogger(LoginController.class);
  /*  @ApiOperation(value = "修改用户信息",response = JSONObject.class, notes = "修改用户信息")
    @PostMapping(value = "/userUpdate")
    public @ResponseBody JSONObject list( HttpSession session,@RequestBody User user){
        JSONObject json = new JSONObject();
        try {
            String host = PropertyUtil.getProperty("safety.host");
            String port = PropertyUtil.getProperty("safety.port");
           // String id = JSONArray.fromObject(list).toString();
//            String result = HttpUtil.doPost("http://"+host+":"+port+"/ms-safety/user/add" ,user);
            System.out.println(JSONObject.fromObject(user));
            System.err.println(JSON.toJSONString(user));
            String result = HttpUtil.doPost("http://192.168.5.37:8070/ms-safety/user/add", JSON.toJSONString(user));
            System.out.println(result);
            json=JSONObject.fromObject(result);
           // json.put("user",JSONObject.fromObject(result));
        } catch (Exception e) {
            e.printStackTrace();
            return (SetStatus.setReturn(0,false,1,"修改用户信息","修改用户信息",""));
        }
        return json;
    }*/

    @ApiOperation(value = "修改用户信息",response = JSONObject.class, notes = "修改用户信息：{'id':116,'mobile':'电话','email':'邮箱'}")
    @PostMapping(value = "/update")
    public @ResponseBody JSONObject list( HttpSession session,@RequestBody Map map){
        JSONObject json = new JSONObject();
        try {
            String host = PropertyUtil.getProperty("safety.host");
            String port = PropertyUtil.getProperty("safety.port");
            String result = HttpUtil.doPost("http://"+host+":"+port+"/ms-safety/user/update", JSONObject.fromObject(map).toString());
            json=JSONObject.fromObject(result);
            if (json.get("type").equals("success")){
                UserInfo userinfo= (UserInfo) session.getAttribute(SessionInfo.USER_INFO);
                userinfo.getUser().setMobile(map.get("mobile").toString());
                userinfo.getUser().setEmail(map.get("email").toString());
            }else {
                return SetStatus.setFunctionType(ReturnType.messageType_right.getType(),ReturnType.warning.toString(),"修改用户信息失败","修改用户信息失败","");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return SetStatus.setFunctionType(ReturnType.messageType_right.getType(),ReturnType.warning.toString(),"修改用户信息失败","修改用户信息失败","");
        }
        return json;
    }


    @PostMapping(value="/editPwd")
    @ApiOperation(value = "修改密码",response = JSONObject.class ,notes = "{'oldPwd':原密码,'newPwd':新密码,'id':用户id}")
    public @ResponseBody JSONObject searchCzr(@RequestBody Map<String,String> map,HttpSession session) {
        JSONObject json = new JSONObject();

        //JSONArray jsonArray=new JSONArray();
        try {
            String host = PropertyUtil.getProperty("safety.host");
            String port = PropertyUtil.getProperty("safety.port");
            JSONObject json_s = new JSONObject();
            json_s.put("id",map.get("id"));
            json_s.put("oldPwd",map.get("oldPwd"));
            json_s.put("newPwd",map.get("newPwd"));
            String result = HttpUtil.doPost("http://"+host+":"+port+"/ms-safety/user/editPwd" ,json_s.toString());
            json=JSONObject.fromObject(result);
            if (json.get("type").equals("success")){
                UserInfo userinfo= (UserInfo) session.getAttribute(SessionInfo.USER_INFO);
                userinfo.getUser().setUserPassword(map.get("newPwd").toString());
            }else{
                return SetStatus.setFunctionType(ReturnType.messageType_right.getType(),ReturnType.warning.toString(),"修改密码失败","修改密码失败","");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return (SetStatus.setReturn(0,false,1,"修改密码失败","修改密码失败",""));
        }
        return json;
    }


    @PostMapping(value="/updateImg")
    @ApiOperation(value = "修改头像路径",response = JSONObject.class,notes = "{'userId':用户id,'path':'头像地址'}" )
    public @ResponseBody JSONObject updateImg(@RequestBody Map<String,String> map,HttpSession session) {
        JSONObject json = new JSONObject();
        try {
            String host = PropertyUtil.getProperty("safety.host");
            String port = PropertyUtil.getProperty("safety.port");
            JSONObject json_s = new JSONObject();
            json_s.put("userId",map.get("userId"));
            json_s.put("path",map.get("path"));
            String result = HttpUtil.doPost("http://"+host+":"+port+"/ms-safety/user/updateImg" ,json_s.toString());
            json=JSONObject.fromObject(result);
            if (json.get("type").equals("success")){
                UserInfo userinfo= (UserInfo) session.getAttribute(SessionInfo.USER_INFO);
                userinfo.getUser().setPhoto(map.get("path").toString());
            }else {
                return SetStatus.setFunctionType(ReturnType.messageType_right.getType(),ReturnType.warning.toString(),"修改头像路径失败","修改头像路径失败","");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return SetStatus.setFunctionType(ReturnType.messageType_right.getType(),ReturnType.warning.toString(),"修改头像路径失败","修改头像路径失败","");
        }
        return json;
    }

  /*  @ApiOperation(value = "用户管理 POST请求查询用户信息",response = JSONObject.class, notes = "POST请求查询用户信息")
    @RequestMapping(value = "/list",method = RequestMethod.POST)
    public @ResponseBody
    JSONObject getSysUser(@RequestBody SysUser entity) throws Exception {
        Page<SysUser> list=new Page<SysUser>();
        JSONObject json = getJSONObject();
        try {
            list= baseService.baseSelectPage(entity,"1");
            json = SetStatus.setSearchType(JSONArray.fromObject(list).toString()
                    ,(int) list.getTotal());
        }catch (Exception e){
            e.printStackTrace();
            json = SetStatus.setFunctionType(1,"error","用户管理",e.getMessage(),"");
        }
        return json;
    }

    @RequestMapping(value = "/sysUser/{id}",method = RequestMethod.GET)
    @ApiOperation(value = "用户管理 根据id查询用户信息",response = JSONObject.class, notes = "GET根据id查询用户信息")
    public @ResponseBody
    JSONObject sysUser(@PathVariable("id") String id) throws Exception {
        JSONObject json = getJSONObject();
        List<SysUser> list =  new ArrayList<SysUser>();
        try {
            SysUser entity=  baseService.baseSelectByPrimaryKey(id,"1");
            if(entity!=null){
                list.add(entity);
                json = SetStatus.setSearchType(JSONArray.fromObject(list).toString()
                        ,list.size());
            }
        } catch (Exception e) {
            e.printStackTrace();
            json = SetStatus.setFunctionType(1,"error","用户管理",e.getMessage(),"");
        }
        return json;

    }*/

  /*  @ApiOperation(value = "添加用户",response = JSONObject.class, notes = "POST新增用户主表")
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public @ResponseBody
    JSONObject addSysUser(@RequestBody SysUser entity) throws Exception {
       // SysUser sysUser=(SysUser)getSessionInfo(SessionInfo.SessionName);
        JSONObject json = getJSONObject();
        try {
            Integer count=baseService.getcount(entity.getDlm(),getSessionDB());
            System.out.println(sysUser.getSsckid()+"====================");
            entity.setSsckid(sysUser.getSsckid());
            baseService.baseInsert(entity,getSessionDB(),(String)getSessionInfo(SessionInfo.SessionBaseDB));
            WmsWarehouse ws=baseService.searchArea(sysUser.getSsckid(),getSessionDB());
            entity.setSsckid(ws.getMc());
            if (count>0) {
               // return SetStatus.setFunctionType(1, "warning", "新增用户", "新增用户失败,登陆名已存在", "");
                return SetStatus.setReturn(0,false,1,"新增用户","新增用户失败,登陆名已存在","");
            }
            return SetStatus.setReturn(1,true,1,"新增用户","新增货主", JSONObject.fromObject(entity).toString());
        }catch (ServiceException e) {
            e.printStackTrace();
            return SetStatus.setReturn(0,false,1,"新增用户",e.getMessage(),"");
        }
    }*/

/*    @ApiOperation(value = "激活and作废 需要传id 与是否激活字段  激活 1  作废2",response = JSONObject.class, notes = "POST激活作废数据")
    @RequestMapping(value = "zuoFie/{id}/{sfyx}",method = RequestMethod.POST)
    public @ResponseBody
    JSONObject activation(@PathVariable("id")String [] id , @PathVariable("sfyx")String sfyx) {
        JSONObject json = getJSONObject();

        try {
           baseService.activation(id,sfyx,getSessionDB(),(String)getSessionInfo(SessionInfo.SessionBaseDB));
       *//*     if (sfyx.equals("1")){
                if(flag == 0){
                    json = SetStatus.setFunctionType(1,"warning","数据激活","激活失败","");
                }else{
                    json = SetStatus.setFunctionType(1,"success","数据激活","激活成功","");
                }
            }else if (sfyx.equals("2")){
                if(flag == 0){
                    json = SetStatus.setFunctionType(1,"warning","数据作废","作废失败","");
                }else{
                    json = SetStatus.setFunctionType(1,"success","数据作废","作废成功","");
                }
            }*//*
            if (sfyx.equals("1")){
                return SetStatus.setReturn(1,true,1,"数据激活","激活","");
            }else if (sfyx.equals("2")){
                return SetStatus.setReturn(1,true,1,"数据作废","作废","");
            }
        }catch (ServiceException e){
            e.printStackTrace();
            return SetStatus.setReturn(0,false,1,"数据激活",e.getMessage(),"");
        }
        return json;
    }*/


 /*   @ApiOperation(value = "角色查询 POST请求查询角色信息",response = JSONObject.class, notes = "POST请求查询角色信息")
    @RequestMapping(value="jsSelect",method= RequestMethod.POST)
    public @ResponseBody
    JSONObject getSysRole(@RequestBody SysRole entity) {
        // Page<SysRole> list = new Page<SysRole>();
        List<SysRole>list=new ArrayList<SysRole>();
        JSONObject json = getJSONObject();
        try {
            list=baseService.jsSelectPage(entity,getSessionDB());
            json = SetStatus.setSearchType(JSONArray.fromObject(list).toString()
                    ,list.size());
        }catch (Exception e) {
            e.printStackTrace();
            json = SetStatus.setFunctionType(1,"error","角色查询",e.getMessage(),"");
        }
        return json;
    }
*/


    /**
     * 赋予角色
     */
/*
    @ApiOperation(value = "赋予角色",response = JSONObject.class, notes = "POST赋予角色,传用户id和角色id")
    @RequestMapping(value = "jsAdd",method= RequestMethod.POST)
    public @ResponseBody
    JSONObject roolUrse(@RequestBody SysRoleUser sru) {
        JSONObject json = getJSONObject();
        try {
            //查询是否有用户ｉｄ
            String ids = sru.getYhid();
            SysRoleUser user=baseService.jsSelectId(ids,getSessionDB());//根据用户查询是否授权
          //如果存在　删除　
           if (user!=null){
                baseService.baseDeleteByPrimaryKey(sru.getYhid(),getSessionDB());
            }
            sru.setId(UUIDUtils.uuid());
           baseService.roolUrse(sru,getSessionDB());
            */
/*if(flag == 0){
                json = SetStatus.setFunctionType(1,"warning","角色授权","角色授权失败","");
            }else{
                json = SetStatus.setFunctionType(1,"success","角色授权","角色授权成功","");
            }*//*

            return SetStatus.setReturn(1,true,1,"赋予角色","赋予角色", JSONObject.fromObject(sru).toString());

        }catch (ServiceException e) {
            e.printStackTrace();
            return SetStatus.setReturn(0,false,1,"赋予角色",e.getMessage(),"");
        }
    }
*/


    /**
     * 数据权限(查询货主)
     */
/*  @ApiOperation(value = "查询货主(数据权限)",response = JSONObject.class, notes = "查询输入{\"mc\":\"货主名称模糊查询\",\"page\":\"当前页\",\"rows\":\"显示当前行\"}")
    @RequestMapping(value = "roleSelect",method = RequestMethod.POST)
    public @ResponseBody
  JSONObject roleSelect(@RequestBody Map map) {
      JSONObject json = getJSONObject();
      Page<WmsOwner> list=new Page<WmsOwner>();
        try {
            list=baseService.roleSelect(map.get("mc")==null?"":map.get("mc").toString(),(Integer)map.get("page"),(Integer) map.get("rows"), getSessionDB());
            json = SetStatus.setSearchType(JSONArray.fromObject(list).toString()
                    ,(int) list.getTotal());
        }catch (Exception e){
            e.printStackTrace();
            json = SetStatus.setFunctionType(1,"error","查询货主",e.getMessage(),"");
        }
        return json;
    }*/

    /**
     * 用户已绑定货主
     * @param id
     * @return
     */
 /*   @RequestMapping(value = "/jsSelect/{id}",method = RequestMethod.GET)
    @ApiOperation(value = "查询用户已绑定货主",response = JSONObject.class, notes = "GET查看用户已绑定货主")
    public @ResponseBody JSONObject jsSelect(@PathVariable("id") String id) {
        JSONObject json = new JSONObject();
        try {
            List<String> list = baseService.jsSelect(id, getSessionDB());
            json.put("ids",list);//往前台传键值对
        } catch (Exception e) {
            e.printStackTrace();
            json = SetStatus.setFunctionType(1, "error", "查看用户已绑定货主", "查看用户已绑定货主失败", "");
        }
        return json;
    }*/


    /**
     * 用户已绑定货主
     * @param id
     * @return
     */
  /*  @RequestMapping(value = "/hzSelectId/{id}",method = RequestMethod.GET)
    @ApiOperation(value = "查询用户已绑定货主",response = JSONObject.class, notes = "GET查看用户已绑定货主")
    public @ResponseBody
    JSONObject sfUser(@PathVariable("id") String id) {
        JSONObject json = getJSONObject();
        try {
            List<String> list =baseService.sfUser(id,getSessionDB());
            json.put("ids",list);//往前台传键值对
        } catch (Exception e) {
            e.printStackTrace();
            json = SetStatus.setFunctionType(1, "error", "查看用户已绑定货主", e.getMessage(), "");
        }
        return json;
    }*/

    /**
     * 用户已绑定角色
     * @param id
     * @return
     */
  /*  @RequestMapping(value = "/jsUser/{id}",method = RequestMethod.GET)
    @ApiOperation(value = "查询用户已绑定角色",response = JSONObject.class, notes = "GET查看用户已绑定角色")
    public @ResponseBody
    JSONObject jsUser(@PathVariable("id") String id) {
        JSONObject json = getJSONObject();
        try {
            List<String> list =baseService.jsUser(id,getSessionDB());
            json.put("ids",list);//往前台传键值对
        } catch (Exception e) {
            e.printStackTrace();
            json = SetStatus.setFunctionType(1, "error", "查看用户已绑定角色", e.getMessage(), "");
        }
        return json;
    }*/

    /**
     *数据权限添加(货主)
     */
  /*  @ApiOperation(value = "货主数据权限添加",response = JSONObject.class, notes = "POST货主数据权限添加,{\"hzid\": [\"id1\", \"id2\"],\"\"yhid\":\"id\"}")
    @RequestMapping(value = "roleAdd",method= RequestMethod.POST)
    public @ResponseBody
    JSONObject roleAdd(@RequestBody Map map) {
        JSONObject json = getJSONObject();
        WmsUserOwner en =new WmsUserOwner();
        try {
            //查询用户是否绑定货主
            String ids  =map.get("yhid").toString();
           List<WmsUserOwner> user=baseService.hzSelectId(ids,getSessionDB());//根据用户查询是否授权
            if (user.size()>0){
                baseService.hzDeleteByPrimaryKey(ids,getSessionDB());
            }
          List<String> hzid= (List)map.get("hzid");
          List<WmsUserOwner> list=new ArrayList<WmsUserOwner>();
         for(int i=0;i<hzid.size();i++){
             WmsUserOwner wuo=new WmsUserOwner();
             wuo.setId(UUIDUtils.uuid());
             wuo.setHzid(hzid.get(i));
             wuo.setYhid(ids);
             list.add(wuo);
         }
         baseService.roleAdd(list,getSessionDB());
            *//* if(flag == 0){
                 json = SetStatus.setFunctionType(1,"warning","货主数据权限添加","货主数据权限添加失败","");
             }else{
                 json = SetStatus.setFunctionType(1,"success","货主数据权限添加","货主数据权限添加成功","");
             }*//*
            return SetStatus.setReturn(1,true,1,"货主数据权限添加","货主数据权限添加", JSONObject.fromObject(map).toString());
        }catch (ServiceException e) {
            e.printStackTrace();
            return SetStatus.setReturn(0,false,1,"新增用户",e.getMessage(),"");
        }
    }*/


    /**
     * 数据权限(查询供应商)
     */
 /*   @ApiOperation(value = "数据权限查询供应商",response = JSONObject.class, notes = "POST数据权限查询供应商")
    @RequestMapping(value = "/supplierSelect",method = RequestMethod.POST)
    public @ResponseBody
    JSONObject supplierSelect(@RequestBody WmsOwnerSupplier entity) {
        Page<WmsOwnerSupplier> list=new Page<WmsOwnerSupplier>();
        JSONObject json = getJSONObject();
        try {
            list=baseService.supplierSelect(entity,getSessionDB());
            json = SetStatus.setSearchType(JSONArray.fromObject(list).toString()
                    ,(int) list.getTotal());
        }catch (Exception e){
            e.printStackTrace();
            json = SetStatus.setFunctionType(1,"error","数据权限查询供应商",e.getMessage(),"");
        }
        return json;
    }*/

    /**
     * 用户已绑定供应商
     * @param id
     * @return
     */
  /*  @RequestMapping(value = "/gysUser/{id}",method = RequestMethod.GET)
    @ApiOperation(value = "查询用户已绑定供应商",response = JSONObject.class, notes = "GET查看用户已绑定供应商")
    public @ResponseBody
    JSONObject gysUser(@PathVariable("id") String id) {
        JSONObject json = new JSONObject();
        try {
            List<String> list = baseService.gysUser(id, getSessionDB());
            json.put("ids",list);//往前台传键值对
        } catch (Exception e) {
            e.printStackTrace();
            json = SetStatus.setFunctionType(1, "error", "查看用户已绑定供应商", e.getMessage(), "");
        }
        return json;
    }
*/
    //**数据权限添加(供应商)
/*

    @ApiOperation(value = "供应商数据权限添加",response = JSONObject.class, notes = "POST供应商数据权限添加,传用户id和供应商id")
    @RequestMapping(value = "supplierAdd",method= RequestMethod.POST)
    public @ResponseBody
    JSONObject supplierAdd(@RequestBody WmsUserSupplier entity) {
        JSONObject json = getJSONObject();
        try {
            //查询是否有用户ｉｄ
            String ids = entity.getYhid();
            WmsUserSupplier user=baseService.gysSelectId(ids,getSessionDB());//根据用户查询是否授权
            //如果存在　删除　
            if (user!=null){
                baseService.gysDeleteByPrimaryKey(entity.getYhid(),getSessionDB());
            }
            entity.setId(UUIDUtils.uuid());
            baseService.supplierAdd(entity,getSessionDB());
            return SetStatus.setReturn(1,true,1,"供应商数据权限添加","供应商数据权限添加", JSONObject.fromObject(entity).toString());
        }catch (ServiceException e) {
            e.printStackTrace();
            return SetStatus.setReturn(0,false,1,"供应商数据权限添加",e.getMessage(),"");
        }
    }
*/

    /**
     * 修改密码
     * @param
     * @return
     */
    // @RequestMapping(params="method=modifypassword")
/*    @ApiOperation(value = "修改密码",response = JSONObject.class, notes = "POST修改密码")
    @RequestMapping(value = "modifypassword/{id}/{mm}/{xmm}",method= RequestMethod.POST)
    public @ResponseBody
    JSONObject modifypassword(@PathVariable("id")String  id , @PathVariable("mm")String mm, @PathVariable("xmm")String xmm){
        JSONObject json = getJSONObject();
        try {
            SysUser u=baseService.baseSelectByPrimaryKey(id,getSessionDB());
           String mm1= generateSalt.toPwdSalt(mm,u.getYz());
            boolean pass=u.getMm().equals(mm1);
            String yz=generateSalt.getSalt();//生成新盐值添加新密码
           // String mms=entity.getMm();
            String mms=generateSalt.toPwdSalt(xmm,yz);
            if(pass){
                Integer flag=baseService.modifyPassword(id,mms,yz,getSessionDB(),(String)getSessionInfo(SessionInfo.SessionBaseDB));
                if(flag==0){
                    json = SetStatus.setFunctionType(1,"warning","修改密码","修改密码失败","");
                }else{
                    json = SetStatus.setFunctionType(1,"success","修改密码","修改密码成功","");
                }
            }else{
                json = SetStatus.setFunctionType(1,"warning","修改密码","修改密码失败,原密码错误","");
            }
        }catch (Exception e){
            logger.error(e.getMessage());
            e.printStackTrace();
            json = SetStatus.setFunctionType(1,"error","修改密码","修改密码失败","");
        }
        return json;
    }*/

    /**
     * 切换货主(查询货主)
     */
  /*  @ApiOperation(value = "切换货主（查询货主）",response = JSONObject.class, notes = "POST切换货主查询货主)")
    @RequestMapping(value = "/switchSelect",method = RequestMethod.POST)
    public @ResponseBody
    JSONObject switchSelect(@RequestBody WmsUserOwner entity) {
        List<WmsUserOwner> list=new ArrayList<WmsUserOwner>();
        JSONObject json = getJSONObject();
        try {
            list=baseService.switchSelect(entity,getSessionDB());
            json = SetStatus.setSearchType(JSONArray.fromObject(list).toString()
                    ,list.size());
        }catch (Exception e){
            logger.error(e.getMessage());
            e.printStackTrace();
            json = SetStatus.setFunctionType(1,"error","切换货主查询货主",e.getMessage(),"");
        }
        return json;
    }*/

    /**
     * 切换货主(查询货主)
     */
    @ApiOperation(value = "查询切换货主", response = JSONObject.class, notes = "POST切换货主查询货主)")
    @PostMapping(value = "/switchSelectId")
    public @ResponseBody
    JSONObject switchSelectId(HttpSession session) { //@PathVariable("id") String id,
        JSONObject jsonObject = new JSONObject();
        try {
            //获取user
            UserInfo userinfo = (UserInfo) session.getAttribute(SessionInfo.USER_INFO);
            List<String> list = userinfo.getDatasetvalues().get("hz");//获取所有货主id
            String ckid = String.valueOf(userinfo.getUser().getOrgId().get(0));//取仓库id
            List<WmsOwner> hz=null;
            if (list.contains("ck_all")){
               //查询所有货主
              List<String> hzid=baseService.hzSelectId(ckid);
                hz=baseService.switchSelectId(hzid);//根据货主id 查询货主名称
            }else {
                hz = baseService.switchSelectId(list);//根据货主id 查询货主名称
            }
            jsonObject.accumulate("id", hz);
        }catch (Exception e) {
            e.printStackTrace();
            jsonObject = SetStatus.setFunctionType(1, "error", "查询切换货主失败", "查询切换货主", "");
        }
        return jsonObject;
    }

    /**
     * 切换货主
     */
    @ApiOperation(value = "切换货主", response = JSONObject.class, notes = "POST切换货主)")
    @PostMapping(value = "/switchShipper")
    public @ResponseBody
    JSONObject switchShipper(@RequestBody SysHz sysHz, HttpSession session) throws SucessException {
        JSONObject jsonObject = new JSONObject();
        try {
            List<SysHz> list=new ArrayList<SysHz>();
            list.add(sysHz);
            session.setAttribute(BaseSessionInfo.SessionConsignor, list);
            List<SysHz> list1=(List<SysHz>) session.getAttribute(BaseSessionInfo.SessionConsignor);
            jsonObject = SetStatus.setFunctionType(1, "success", "切换货主成功", "切换货主", "");
        }catch (Exception e) {
            e.printStackTrace();
            jsonObject = SetStatus.setFunctionType(1, "error", "切换货主失败", "切换货主", "");
        }
        return jsonObject;
    }

    /**
     * 查询仓库信息
     * @param map
     * @return
     */
 /*   @RequestMapping(value = "/addSearchArea",method = RequestMethod.POST,produces = {"application/json;charset=UTF-8"})
    @ApiOperation(value = "用户管理 新增用户仓库模糊查询",response = JSONObject.class, notes = "查询输入{\"mc\":\"仓库信息模糊查询\"}")
    public @ResponseBody
    JSONArray addSearch(@RequestBody Map<String,String> map) {
        JSONArray jsonArray = new JSONArray();
        try {
            List<WmsWarehouse> list = baseService.addSearchArea(map.get("mc"),getSessionDB());
            for (int i = 0; i < list.size(); i++) {
                WmsWarehouse wmsWarehouse =  list.get(i);
                JSONObject json = new JSONObject();
                json.put("dictionaryid",wmsWarehouse.getId());
                json.put("value",wmsWarehouse.getMc());
                jsonArray.add(json);
            }
        } catch (Exception e) {
            logger.error(e.getMessage());
            e.printStackTrace();
        }
        return jsonArray;
    }

    *//**
     * 模糊查询货主信息
     * @param map
     * @return
     *//*
    @RequestMapping(value = "/hzSearch",method = RequestMethod.POST,produces = {"application/json;charset=UTF-8"})
    @ApiOperation(value = "用户管理 货主模糊查询",response = JSONObject.class, notes = "查询输入{\"mc\":\"货主信息模糊查询\"}")
    public @ResponseBody
    JSONArray hzSearch(@RequestBody Map<String,String> map) {
        JSONArray jsonArray = new JSONArray();
        try {
            List<WmsOwner> list = baseService.hzSearch(map.get("mc"),getSessionDB());
            for (int i = 0; i < list.size(); i++) {
                WmsOwner WmsOwner =  list.get(i);
                JSONObject json = new JSONObject();
                json.put("dictionaryid",WmsOwner.getId());
                json.put("value",WmsOwner.getMc());
                jsonArray.add(json);
            }
        } catch (Exception e) {
            logger.error(e.getMessage());
            e.printStackTrace();
        }
        return jsonArray;
    }

    *//**
     * 查询角色
     * @param map
     * @return
     *//*
    @RequestMapping(value = "/addSearchJs",method = RequestMethod.POST,produces = {"application/json;charset=UTF-8"})
    @ApiOperation(value = "用户管理 角色模糊查询",response = JSONObject.class, notes = "查询输入{\"mc\":\"角色模糊查询\"}")
    public @ResponseBody
    JSONArray addSearchJs(@RequestBody Map<String,String> map) {
        JSONArray jsonArray = new JSONArray();
        try {
            List<SysRole> list = baseService.addSearchJs(map.get("mc"),map.get("yhid"),getSessionDB());
            for (int i = 0; i < list.size(); i++) {
                SysRole sysRoles =  list.get(i);
                JSONObject json = new JSONObject();
                json.put("dictionaryid",sysRoles.getId());
                json.put("value",sysRoles.getMc());
                jsonArray.add(json);
            }
        } catch (Exception e) {
            logger.error(e.getMessage());
            e.printStackTrace();
        }
        return jsonArray;
    }


    *//**
     * 查询供应商
     * @param map
     * @return
     *//*
    @RequestMapping(value = "/addSearchGys",method = RequestMethod.POST,produces = {"application/json;charset=UTF-8"})
    @ApiOperation(value = "用户管理 供应商模糊查询", notes = "查询输入{\"mc\":\"供应商模糊查询\"}")*//*response = JSONObject.class,*//*
    public @ResponseBody
    JSONArray addSearchGys(@RequestBody Map<String,String> map) {
        JSONArray jsonArray = new JSONArray();
        try {
            List<WmsOwnerSupplier> list = baseService.addSearchGys(map.get("mc"),getSessionDB());
            for (int i = 0; i < list.size(); i++) {
                WmsOwnerSupplier wmsOwnerSupplier =  list.get(i);
                JSONObject json = new JSONObject();
                json.put("dictionaryid",wmsOwnerSupplier.getId());
                json.put("value",wmsOwnerSupplier.getMc());
                jsonArray.add(json);
            }
        } catch (Exception e) {
            logger.error(e.getMessage());
            e.printStackTrace();
        }
        return jsonArray;
    }

    *//**
     * 重置密码
     *//*
   @ApiOperation(value = "用户管理  重置密码",response = JSONObject.class, notes = "POST重置密码")
    @RequestMapping(value = "resetpassword/{id}",method= RequestMethod.POST)
    public @ResponseBody
   JSONObject resetpassword(@PathVariable("id") String[] id){
       JSONObject json = getJSONObject();
       boolean b=false;
       try {
           //根据id 查询盐值
           b = baseService.resetpassword(id,getSessionDB(),(String)getSessionInfo(SessionInfo.SessionBaseDB));
           if (b){
               json = SetStatus.setFunctionType(1,"success","重置密码","重置密码成功","1");
           }else {
               json = SetStatus.setFunctionType(1,"warning","重置密码","重置密码失败","0");
           }
       }catch (Exception e){
           logger.error(e.getMessage());
           e.printStackTrace();
           json = SetStatus.setFunctionType(1,"error","重置密码","重置密码失败","0");
       }
        return json;
    }*/
}

